Cycle Detection in Directed graphs